class HotelModel {
  final String id;
  final String name;
  final String nameEn;
  final String description;
  final String destinationId;
  final String
  category; // 酒店类型：luxury, business, budget, boutique, resort, etc.
  final int starRating; // 星级评定 1-5
  final double latitude;
  final double longitude;
  final String address;
  final List<String> images;
  final String coverImage;
  final double rating;
  final int reviewCount;
  final List<String> tags;
  final Map<String, dynamic>
  priceRange; // {"min": 100, "max": 500, "currency": "EUR"}
  final List<String> amenities; // 设施：wifi, pool, gym, spa, restaurant, etc.
  final Map<String, String>
  policies; // 政策：checkin, checkout, cancellation, etc.
  final List<Map<String, dynamic>> roomTypes; // 房型信息
  final String phone;
  final String email;
  final String website;
  final bool isBookable; // 是否可预订
  final DateTime createdAt;
  final DateTime updatedAt;

  HotelModel({
    required this.id,
    required this.name,
    required this.nameEn,
    required this.description,
    required this.destinationId,
    required this.category,
    required this.starRating,
    required this.latitude,
    required this.longitude,
    required this.address,
    required this.images,
    required this.coverImage,
    required this.rating,
    required this.reviewCount,
    required this.tags,
    required this.priceRange,
    required this.amenities,
    required this.policies,
    required this.roomTypes,
    required this.phone,
    required this.email,
    required this.website,
    required this.isBookable,
    required this.createdAt,
    required this.updatedAt,
  });

  factory HotelModel.fromJson(Map<String, dynamic> json) {
    return HotelModel(
      id: json['_id'] ?? json['id'] ?? '',
      name: json['name'] ?? '',
      nameEn: json['nameEn'] ?? '',
      description: json['description'] ?? '',
      destinationId: json['destinationId'] ?? '',
      category: json['category'] ?? '',
      starRating: json['starRating'] ?? 3,
      latitude: (json['latitude'] ?? 0.0).toDouble(),
      longitude: (json['longitude'] ?? 0.0).toDouble(),
      address: json['address'] ?? '',
      images: List<String>.from(json['images'] ?? []),
      coverImage: json['coverImage'] ?? '',
      rating: (json['rating'] ?? 0.0).toDouble(),
      reviewCount: json['reviewCount'] ?? 0,
      tags: List<String>.from(json['tags'] ?? []),
      priceRange: Map<String, dynamic>.from(json['priceRange'] ?? {}),
      amenities: List<String>.from(json['amenities'] ?? []),
      policies: Map<String, String>.from(json['policies'] ?? {}),
      roomTypes: List<Map<String, dynamic>>.from(json['roomTypes'] ?? []),
      phone: json['phone'] ?? '',
      email: json['email'] ?? '',
      website: json['website'] ?? '',
      isBookable: json['isBookable'] ?? true,
      createdAt:
          json['createdAt'] != null
              ? DateTime.parse(json['createdAt'])
              : DateTime.now(),
      updatedAt:
          json['updatedAt'] != null
              ? DateTime.parse(json['updatedAt'])
              : DateTime.now(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'nameEn': nameEn,
      'description': description,
      'destinationId': destinationId,
      'category': category,
      'starRating': starRating,
      'latitude': latitude,
      'longitude': longitude,
      'address': address,
      'images': images,
      'coverImage': coverImage,
      'rating': rating,
      'reviewCount': reviewCount,
      'tags': tags,
      'priceRange': priceRange,
      'amenities': amenities,
      'policies': policies,
      'roomTypes': roomTypes,
      'phone': phone,
      'email': email,
      'website': website,
      'isBookable': isBookable,
      'createdAt': createdAt.toIso8601String(),
      'updatedAt': updatedAt.toIso8601String(),
    };
  }
}
